package com.lyh.example.weixin_demo_back.controller;

import com.lyh.example.weixin_demo_back.entity.LocalLiftGirdImages;
import com.lyh.example.weixin_demo_back.entity.LocalLiftSwiperImage;
import com.lyh.example.weixin_demo_back.entity.Shop;
import com.lyh.example.weixin_demo_back.vo.ShopListVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@RestController
@RequestMapping("/api")
public class LocalLifeController {
    @ApiOperation("轮播图")
    @GetMapping("/getSwiperList")
    public ResponseMessage<List<LocalLiftSwiperImage>> getSwiperList() {
        List<LocalLiftSwiperImage> list = new ArrayList<>();
        LocalLiftSwiperImage image = new LocalLiftSwiperImage("1","http://www.lyh.com:8080/static/swipter/test1.jpg","");
        LocalLiftSwiperImage image2 = new LocalLiftSwiperImage("2","http://www.lyh.com:8080/static/swipter/test2.jpg","");
        list.add(image);
        list.add(image2);
        return ResponseMessage.ok(list);
    }
    @ApiOperation("轮播图")
    @GetMapping("/getGridList")
    public ResponseMessage<List<LocalLiftGirdImages>> getGridList() {
        List<LocalLiftGirdImages> list = new ArrayList<>();
        LocalLiftGirdImages image1 = new LocalLiftGirdImages("1","http://www.lyh.com:8080/static/grid/adobe-illustrate_adobe-illustrate.svg",  "美食",  "");
        LocalLiftGirdImages image2 = new LocalLiftGirdImages("2","http://www.lyh.com:8080/static/grid/AirPods_airpods.svg",  "洗浴足疗","");
        LocalLiftGirdImages image3 = new LocalLiftGirdImages("3","http://www.lyh.com:8080/static/grid/DVI_dvi.svg",  "结婚啦", "");
        LocalLiftGirdImages image4 = new LocalLiftGirdImages("4","http://www.lyh.com:8080/static/grid/F4_f-four-key.svg", "卡拉OK", "");
        LocalLiftGirdImages image5 = new LocalLiftGirdImages("5","http://www.lyh.com:8080/static/grid/F9_f-nine-key.svg",  "找工作", "");
        LocalLiftGirdImages image6 = new LocalLiftGirdImages("6","http://www.lyh.com:8080/static/grid/Fn_f-n-key.svg",  "辅导班", "");
        LocalLiftGirdImages image7 = new LocalLiftGirdImages("7","http://www.lyh.com:8080/static/grid/h_h.svg","汽车保养",  "");
        LocalLiftGirdImages image8 = new LocalLiftGirdImages("8","http://www.lyh.com:8080/static/grid/instagram_instagram.svg",  "租房",  "");
        LocalLiftGirdImages image9 = new LocalLiftGirdImages("9","http://www.lyh.com:8080/static/grid/RS_rs-male.svg",  "装修",  "");
        list.add(image1);
        list.add(image2);
        list.add(image3);
        list.add(image4);
        list.add(image5);
        list.add(image6);
        list.add(image7);
        list.add(image8);
        list.add(image9);
        return ResponseMessage.ok(list);
    }
    @ApiOperation("获取颜色列表")
    @GetMapping("/getColorList")
    public ResponseMessage<List<String>> getColorList() {
        List<String> list = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            String color = String.format("%s,%s,%s",
                    random.nextInt(256), random.nextInt(256),random.nextInt(256));
            list.add(color);
        }
        return ResponseMessage.ok(list);
    }
    @ApiOperation("getShoList")
    @GetMapping("/getShopList/{id}")
    public ResponseMessage<ShopListVo> getShoList(@PathVariable("id") String id, @RequestParam("page") int page,  @RequestParam("size")int size) {
        ShopListVo vo = new ShopListVo();
        if(page > 10){
            return ResponseMessage.ok(vo);
        }
//        ShopListVo vo = new ShopListVo();
        List<Shop> shops = new ArrayList<>();
        for (int i = (page-1)*size; i < page*size; i++){
            Shop shop = new Shop();
            shop.setId(id + "_"+ String.valueOf(i));
            shop.setName("手抓饭"+i);
            shop.setAddress("苏州市工业园区"+i +"号");
            shop.setPhone("1505152148"+i);
            shop.setImage("http://www.lyh.com:8080/static/grid/AirPods_airpods.svg");
            List<String> images = new ArrayList<>();
            images.add("http://www.lyh.com:8080/static/grid/AirPods_airpods.svg");
            images.add("http://www.lyh.com:8080/static/grid/AirPods_airpods.svg");
            images.add("http://www.lyh.com:8080/static/grid/AirPods_airpods.svg");
            images.add("http://www.lyh.com:8080/static/grid/AirPods_airpods.svg");
            images.add("http://www.lyh.com:8080/static/grid/AirPods_airpods.svg");
            images.add("http://www.lyh.com:8080/static/grid/AirPods_airpods.svg");
            images.add("http://www.lyh.com:8080/static/grid/AirPods_airpods.svg");
            images.add("http://www.lyh.com:8080/static/grid/AirPods_airpods.svg");
            images.add("http://www.lyh.com:8080/static/grid/AirPods_airpods.svg");
            shop.setImages(images);
            shop.setTime("8:00:00-15:00:00");
            shops.add(shop);
        }
        vo.setShops(shops);
        vo.setTotalPage(10);
        return ResponseMessage.ok(vo);
    }

}
